package com.zxing.spring.customer.service;

import com.zxing.spring.customer.dao.PersonDao;
import com.zxing.spring.customer.entity.PersonEntity;
import com.zxing.spring.customer.client.HiClient;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HelloService {

    @Autowired
    private PersonDao personDao;
    @Autowired
    private HiClient hiClient;

    @GlobalTransactional(rollbackFor = Exception.class)
    public String hiGet(){
        String s = hiClient.hiGet();
        PersonEntity person = new PersonEntity();
        person.setAccount("rollback");
        person.setName("name-"+s);
        person.setPwd("1");
        personDao.insert(person);
        return s;
    }
}
